#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 2e5+10;
const int L = 1 << 19;

int n,m,c[N],Q,tot[N],l;
vector<pii> qes[N];

struct BIT{
	int arr[L];
	void add(int x,int y){x++;for(;x <= l;x += x & -x) arr[x] ^= y;}
	int query(int x,int y = 0){x++;for(;x;x -= x & -x) y ^= arr[x];return y;}
	void reset(){memset(arr,0,sizeof arr);}
}T;

void solve(int bit){
	T.reset(); l = 1 << bit + 1;
	for(int i = m;i;i--){
		if(c[i]) T.add(i & (l - 1),1);
		for(auto q : qes[i]){
			int x = q.fi & (l - 1),id = q.se;
			if(x >> bit & 1) tot[id] ^= (T.query(x - (1 << bit) - 1) ^ T.query(x - 1)) << bit;
			else tot[id] ^= (T.query(x - 1) ^ T.query(l - 1) ^ T.query(x + (1 << bit) -1)) << bit;
		}
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in; for(int i = 1,x;i <= n;i++) x = in,c[x] ^= 1;
	Q = in;
	for(int i = 1,x,y;i <= Q;i++) x = in,y = in,qes[x].pb(pii(x,i)),qes[y+1].pb(pii(x,i));
	for(int i = 0;i < 18;i++) solve(i);
	for(int i = 1;i <= Q;i++) putchar(tot[i] ? 'A' : 'B');
	puts("");
	return 0;
}
